<template>
  <j-modal
    title="处置"
    :width="width"
    :visible="visible"
    switchFullscreen
    @ok="handleOk"
    :okButtonProps="{ class: { 'jee-hidden': disableSubmit } }"
    @cancel="handleCancel"
    cancelText="关闭"
  >
    <a-spin :spinning="confirmLoading">
      <a-form-model ref="form" :model="form" :rules="validatorRules">
        <a-form-model-item label="处置人" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-model="form.dealBy" :disabled=true placeholder="" />
        </a-form-model-item>
        <a-form-model-item label="处置内容" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dealContent">
          <a-textarea v-model="form.dealContent" placeholder="请输入" :auto-size="{ minRows: 4, maxRows: 6 }" />
        </a-form-model-item>
      </a-form-model>
    </a-spin>
  </j-modal>
</template>

<script>
import * as alarmApi from '@/api/alarm.js'
import { mapGetters } from 'vuex'
export default {
  name: 'HandleModal',
  components: {},
  data() {
    return {
      labelCol: {
        xs: { span: 10 },
        sm: { span: 5 },
      },
      wrapperCol: {
        xs: { span: 10 },
        sm: { span: 16 },
      },
      width: 600,
      visible: false,
      form: {
        dealBy: '',
        dealContent:'',
        id:''
      },
      disableSubmit: false,
      confirmLoading: false,
      id: '',
      validatorRules: {
        dealContent: [{ required: true, message: '请输入处置内容!' }],
      },
    }
  },
  async created() {},
  methods: {
    ...mapGetters(['nickname']),
    init() {
      
    },
    show(id) {
      this.form.dealBy = this.nickname()
      this.form.id = id
      this.form.dealContent = ""
      this.visible = true
    },
    close() {
      this.$emit('close')
      this.visible = false
    },
    handleOk() {
      this.$refs.form.validate((valid) => {
        if (valid) {
          this.confirmLoading = true
          alarmApi.smuInfoWarnEdit(this.form)
            .then((res) => {
              if (res.success) {
                this.$message.success(res.message)
                this.$emit('ok')
              } else {
                this.$message.warning(res.message)
              }
            })
            .catch((e) => {
              this.$message.warn('请求失败！')
            })
            .finally(() => {
              this.confirmLoading = false
              this.close()
            })
        }
      })
    },
    handleCancel() {
      this.close()
    },
  },
}
</script>
<style lang="less" scoped>

</style>
